function info(message, time, base)
{

	text = "";
	
	switch(message)
	{
		case 101 : text = "User has successfully been created. You can now login."; break;
		case 102 : text = "GRE has successfully been written to the database."; break;
		case 103 : text = "Link has succesfully been created."; break;
	
		case 200 : text = "There was an undefined error. Please try again."; break;
		case 201 : text = "Login failed. Please retry."; break;
		case 202 : text = "Passwords are not the same. Please retry."; break;
		case 203 : text = "Mail address already in database. Login directly or use other mail address to register."; break;
		case 204 : text = "Error while writing GRE to database. Please try again."; break;
		case 205 : text = "Error while generating link. Please apply first."; break;
		
		default : text = "Something went wront! Sorry, try again.";
	}
	
	var info = document.createElement('div');

	info.setAttribute('id', 'info');

	if(message < 200)
	{
		info.setAttribute('class', 'hint');
		info.innerHTML = "<table><tr><td><img src=\"" + base + "img/hint.png\" alt=\"Info\"></td><td>" + text + "</td></tr></table>";
	}
	else if(message > 200)
	{
		info.setAttribute('class', 'error');
		info.innerHTML = "<table><tr><td><img src=\"" + base + "img/error.png\" alt=\"Error\"></td><td>" + text + "</td></tr></table>";
	}
	
	document.getElementById('message').appendChild(info);
	infoElement = document.getElementById('info');
	var t = setTimeout("document.getElementById('message').removeChild(infoElement)", time*1000);
}

function isMail(wort)
{
	if(wort.match(/\w*@\w.*\.\w\w*/)==null)
	{
		document.form.mail.focus();
		info(204, 5);
	}
}

function isText(element) 
{	
	  text = true;
      checkText = element.value.toUpperCase();
      
      console.log(checkText);
      
      if(checkText.length == 0)
      {
         text = false;
      }
      else
      {
         for(n = 0; n < checkText.length; n++)
         {
        	 if(checkText.charAt(n) < "A" || checkText.charAt(n) > "Z")
        	 {
        		 text = false;
        	 }
         }
      }
      
      if(!text)
      {
    	 info(203, 5);
         document.form.element.focus();
      }
}
 
function isNumber(wort) 
{ 
   ist_zahl=true;
   if(wort.length==0)
      ist_zahl=false;
   else 
      for(n=0;n<wort.length;n++)
         {if(wort.charAt(n)<"0"||wort.charAt(n)>"9")ist_zahl=false;}
   if(!ist_zahl)
       alert("Bitte eine g&uuml;ltige Zahl eingeben!"); 
} 

function complete() 
{ 
   voll=true; 
   for(n=0;n<25;n++) 
   {
       if(window.document.form.elements[n].value== "") 
       voll=false;
   }
   if(!voll)alert("Please fill in all fields!"); 
   return voll; 
} 